

package com.hazelcast.jet.accumulator;

/**
 * Mutable container of a {@code long} and a {@code double} value.
 *
 * @since Jet 3.0
 */
public class LongDoubleAccumulator {

    private long longValue;
    private double doubleValue;

    /**
     * Creates a new instance with values equal to 0.
     */
    public LongDoubleAccumulator() {
    }

    /**
     * Creates a new instance with the specified values.
     */
    public LongDoubleAccumulator(long longValue, double doubleValue) {
        this.longValue = longValue;
        this.doubleValue = doubleValue;
    }

    /**
     * Returns the {@code long} value.
     */
    public long getLong() {
        return longValue;
    }

    /**
     * Sets the {@code long} value.
     */
    public void setLong(long value1) {
        this.longValue = value1;
    }

    /**
     * Returns the {@code double} value.
     */
    public double getDouble() {
        return doubleValue;
    }

    /**
     * Sets the {@code double} value.
     */
    public void setDouble(double value2) {
        this.doubleValue = value2;
    }

    @Override
    public boolean equals(Object o) {
        return this == o || o != null && this.getClass() == o.getClass() && this.longValue == ((LongDoubleAccumulator) o).longValue && Double.compare(this.doubleValue, ((LongDoubleAccumulator) o).doubleValue) == 0;
    }

    @Override
    public int hashCode() {
        int result;
        result = (int) (longValue ^ (longValue >>> 32));
        long temp = Double.doubleToLongBits(doubleValue);
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        return result;
    }

    @Override
    public String toString() {
        return "LongLongAccumulator(" + longValue + ", " + doubleValue + ')';
    }
}
